package com.zy.springboot.mall_spring_boot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

@Controller
public class HelloController {
    @RequestMapping(value="/hello",produces="application/json;charset=utf-8")
    public String index(HttpServletRequest req, HttpServletResponse res) {
        //utf-8 utf-8 1 2 2 un
//        res.setContentType("image/png");
        return "Hello World";
    }


    @GetMapping("/")
    public String index(ModelMap map) {
        map.addAttribute("host", "http://www.baidu.com");
        return "index";
    }
}
